import { computed } from 'vue'
import { useStore, mapState } from 'vuex'

export default function useUserState(mapper) {
  const store = useStore()
  const stateFnObj = mapState(mapper)

  const newState = {}
  Object.keys(stateFnObj).forEach((key) => {
    const fn = stateFnObj[key]
    newState[key] = computed(fn.bind({ $store: store }))
  })

  return newState
}